VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsRegistry"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

'registry variables
Private Const REG_SZ = (1)
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const KEY_ALL_ACCESS = &H3F
Private Const ERROR_SUCCESS = 0&
Private Const REG_OPTION_NON_VOLATILE = 0&

'property variables
Private mstrArchiveFileLocation As String
Private mstrErrorFileLocation As String
Private mstrAsciiFileName As String
Private mstrResponseFileType As String

Public Property Let AdoConnectString(ByVal vData As String)
   'sets the system in the registry
    SaveSettingC "Software\Mindkey Software Solutions\KeyTax", "AdoConnectString", vData, REG_SZ
End Property
Public Property Get AdoConnectString() As String
    'gets the system from the registry
    AdoConnectString = GetSettingC("Software\Mindkey Software Solutions\KeyTax", "AdoConnectString")
End Property


Public Property Let AsciiFileLocation(ByVal vData As String)
   'sets the system in the registry
    SaveSettingC "Software\Mindkey Software Solutions\KeyTax", "AsciiFileLocation", vData, REG_SZ
    mstrArchiveFileLocation = vData & "Archive\"
    mstrErrorFileLocation = vData & "Error\"
    
    If Dir(mstrArchiveFileLocation, vbDirectory) = "" Then
        MkDir mstrArchiveFileLocation
    End If
    If Dir(mstrErrorFileLocation, vbDirectory) = "" Then
        MkDir mstrErrorFileLocation
    End If
    
End Property
Public Property Get AsciiFileLocation() As String
    'gets the system from the registry
    AsciiFileLocation = GetSettingC("Software\Mindkey Software Solutions\KeyTax", "AsciiFileLocation")
End Property

Public Property Get ArchiveFileLocation() As String
    'gets the system from the registry
    ArchiveFileLocation = mstrArchiveFileLocation
End Property

Public Property Get ErrorFileLocation() As String
    'gets the system from the registry
    ErrorFileLocation = mstrErrorFileLocation
End Property

Public Property Let AsciiFileName(vData As String)
  mstrAsciiFileName = vData
End Property
Public Property Get AsciiFileName() As String
  AsciiFileName = mstrAsciiFileName
End Property
Public Property Let ResponseFileType(vData As String)

    '13062001 - 3 types of response files:
    'Directive Request Validation Response  (IRP3RSP)
    'Processed Directives Response          (IRP3DIRS)
    'processed Cancel Responses             (IRP3CRP)
    'will determine which by:
    'VR = Validation Response
    'DR = Directive Response
    'CR = Cancelled Response


    mstrResponseFileType = vData
End Property
Public Property Get ResponseFileType() As String
  ResponseFileType = mstrResponseFileType
End Property


Private Sub SaveSettingC(strKeyName As String, strValueName As String, varValueSetting As Variant, lngValueType As Long)
'Purpose
'*******
'Set the value of a Registry key if it exists.
'if the registry key doesn't exist it will be created

On Error GoTo SaveSettingsCFix

'Variables
'*********
    Dim hKey As Long            'Handle to the key
    Dim lngRetVal As Long       'Result of API functions
    Dim SA As TSECURITY_ATTRIBUTES
    Dim create As Long

'Code
'****
    'Open or Ceate the registry key
    lngRetVal = RegCreateKeyEx(HKEY_LOCAL_MACHINE, strKeyName, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, SA, hKey, create)
    If lngRetVal <> ERROR_SUCCESS Then
        MsgBox "An error occured while trying to set the registry key", vbExclamation
        Exit Sub
    End If
    
    'Set or create a registry value
    lngRetVal = RegSetValueEx(hKey, strValueName, 0, lngValueType, varValueSetting, CLng(Len(varValueSetting) + 1))
        
    RegCloseKey (hKey)
    
    Exit Sub
    
SaveSettingsCFix:
    MsgBox "Options.SavesSettingsC: ", Err.Description
    
End Sub


Private Function GetSettingC(strKeyName As String, strValueName As String) As String
'Purpose
'*******
'Gets the value a certain registry key

On Error GoTo GetSettingsCFix

'Variables
'*********
    Dim lngRetVal As Long           'Result of the API functions
    Dim hKey As Long                'Handle of the opened key
    Dim szBuffer As String          'Setting of the queried value
    Dim lngBuffSize As Long
    
'Code
'****
    'Create the buffer
    szBuffer = Space(255)
    lngBuffSize = 255
    
    'Open the specified registry key
    lngRetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKeyName, 0, KEY_ALL_ACCESS, hKey)
    If lngRetVal <> ERROR_SUCCESS Then
        'MsgBox "Registry key or Value Name doesn't exist", vbExclamation
        Exit Function
    End If
    
    'Read the opened registry key
    lngRetVal = RegQueryValueEx(hKey, strValueName, 0, 0, szBuffer, lngBuffSize)
    
    GetSettingC = Trim(Left(szBuffer, lngBuffSize - 1))
    
    'Close the registry key
    RegCloseKey (hKey)

    Exit Function
    
GetSettingsCFix:
    MsgBox "clsOptions.GetSettingsC: " & Err.Description
    
End Function
